﻿using UnityEngine;
using TMPro;
using pooling;

public class ScoreAnimation : PoolingObject
{
    private TextMeshPro scoreText;

    private void Awake()
    {
        scoreText = GetComponent<TextMeshPro>();
    }

    public void InitAnimation(Vector3 position, int score)
    {
        transform.position = position;
        scoreText.color -= new Color(0, 0, 0, 1);
        scoreText.text = score.ToString();

        scoreText.LeanAlphaTextMeshPro(1, 0.5f).setEase(LeanTweenType.easeOutCubic).setOnComplete(()=> {
            scoreText.LeanAlphaTextMeshPro(0, 0.3f);
        });
        gameObject.LeanMoveLocalY(transform.position.y + 2f, 0.8f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() =>
        {
            OnRelease();
        });
    }
}
